package com.zhiwang.xiaoqu.widget.webview

import android.graphics.Bitmap
import android.net.http.SslError
import android.os.Message
import android.view.KeyEvent
import android.webkit.*

interface WebViewClientCallBack {

    fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean = false

    fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean = false

    fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
        //no op
    }

    fun onPageFinished(view: WebView?, url: String?) {
        //no op
    }


    fun onLoadResource(view: WebView?, url: String?) {
        //no op
    }


    fun onPageCommitVisible(view: WebView?, url: String?) {
        //no op
    }

    fun shouldInterceptRequest(view: WebView?, url: String?): WebResourceResponse? = null


    fun shouldInterceptRequest(view: WebView?, request: WebResourceRequest?): WebResourceResponse?= null

    fun onTooManyRedirects(view: WebView?, cancelMsg: Message?, continueMsg: Message?){

    }

    fun onReceivedError(view: WebView?, errorCode: Int, description: String?, failingUrl: String?){

    }

    fun onReceivedError(view: WebView?, request: WebResourceRequest?, error: WebResourceError?){

    }

    fun onReceivedHttpError(view: WebView?, request: WebResourceRequest?, errorResponse: WebResourceResponse?){

    }

    fun onFormResubmission(view: WebView?, dontResend: Message?, resend: Message?){

    }

    fun doUpdateVisitedHistory(view: WebView?, url: String?, isReload: Boolean?){

    }

    fun onReceivedSslError(view: WebView?, handler: SslErrorHandler?, error: SslError?){

    }

    fun onReceivedClientCertRequest(view: WebView?, request: ClientCertRequest?){

    }


    fun onReceivedHttpAuthRequest(view: WebView?, handler: HttpAuthHandler?, host: String?, realm: String?){

    }

    fun shouldOverrideKeyEvent(view: WebView?, event: KeyEvent?): Boolean = false

    fun onUnhandledKeyEvent(view: WebView?, event: KeyEvent?){

    }

    fun onScaleChanged(view: WebView?, oldScale: Float, newScale: Float){

    }

    fun onReceivedLoginRequest(view: WebView?, realm: String?, account: String?, args: String?){

    }

    fun onRenderProcessGone(view: WebView?, detail: RenderProcessGoneDetail?): Boolean = false

    fun onSafeBrowsingHit(view: WebView?, request: WebResourceRequest?, threatType: Int, callback: SafeBrowsingResponse?){

    }
}